package com.skyolder.milkbee.domain;

import io.swagger.annotations.ApiModel;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.io.Serializable;
import java.time.ZonedDateTime;
import java.util.Objects;

/**
 * Trade 交易
 * createdAt 创建时间
 * fromUserId  发送人Id
 * toUserId 接受人Id
 * gold 金币数量
 */
@ApiModel(description = "Trade 交易 createdAt 创建时间 fromUserId  发送人Id toUserId 接受人Id gold 金币数量")
@Entity
@Table(name = "trade")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Trade implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(name = "created_at")
    private ZonedDateTime createdAt;

    @Column(name = "from_user_id")
    private Long fromUserId;

    @Column(name = "to_user_id")
    private Long toUserId;

    @Column(name = "from_leaguer_id")
    private Long fromLeaguerId;

    @Column(name = "to_leaguer_id")
    private Long toLeaguerId;

    @Column(name = "gold")
    private Long gold;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public ZonedDateTime getCreatedAt() {
        return createdAt;
    }

    public Trade createdAt(ZonedDateTime createdAt) {
        this.createdAt = createdAt;
        return this;
    }

    public void setCreatedAt(ZonedDateTime createdAt) {
        this.createdAt = createdAt;
    }

    public Long getFromUserId() {
        return fromUserId;
    }

    public Trade fromUserId(Long fromUserId) {
        this.fromUserId = fromUserId;
        return this;
    }

    public void setFromUserId(Long fromUserId) {
        this.fromUserId = fromUserId;
    }

    public Long getToUserId() {
        return toUserId;
    }

    public Trade toUserId(Long toUserId) {
        this.toUserId = toUserId;
        return this;
    }

    public void setToUserId(Long toUserId) {
        this.toUserId = toUserId;
    }

    public Long getFromLeaguerId() {
        return fromLeaguerId;
    }

    public Trade fromLeaguerId(Long fromLeaguerId) {
        this.fromLeaguerId = fromLeaguerId;
        return this;
    }

    public void setFromLeaguerId(Long fromLeaguerId) {
        this.fromLeaguerId = fromLeaguerId;
    }

    public Long getToLeaguerId() {
        return toLeaguerId;
    }

    public Trade toLeaguerId(Long toLeaguerId) {
        this.toLeaguerId = toLeaguerId;
        return this;
    }

    public void setToLeaguerId(Long toLeaguerId) {
        this.toLeaguerId = toLeaguerId;
    }

    public Long getGold() {
        return gold;
    }

    public Trade gold(Long gold) {
        this.gold = gold;
        return this;
    }

    public void setGold(Long gold) {
        this.gold = gold;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Trade trade = (Trade) o;
        if (trade.id == null || id == null) {
            return false;
        }
        return Objects.equals(id, trade.id);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(id);
    }

    @Override
    public String toString() {
        return "Trade{" +
            "id=" + id +
            ", createdAt='" + createdAt + "'" +
            ", fromUserId='" + fromUserId + "'" +
            ", toUserId='" + toUserId + "'" +
            ", fromLeaguerId='" + fromLeaguerId + "'" +
            ", toLeaguerId='" + toLeaguerId + "'" +
            ", gold='" + gold + "'" +
            '}';
    }
}
